<template>
    <div class="mui-numbox" data-numbox-min='1' :data-numbox-max='max'>
        <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
        <input id="count" class="mui-input-numbox" type="number" @change="postNum" ref="count"/>
        <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
</template>

<script>
    import mui from '../../lib/mui/js/mui.min.js'

    export default {
        mounted() {
            mui(".mui-numbox").numbox();
        },
        methods: {
            postNum() {
                // 第一种方式(只是回忆一下js)
                // console.log(document.getElementById('count').value);
                // 第二种
                this.$emit('getNum', parseInt(this.$refs.count.value));
            }
        },
        props: ['max'],
        watch: {
            max: function (newVal, oldVal){      //mui中提供的jsApi
                mui('.mui-numbox').numbox().setOption('max', newVal);
             }
        }
    }
</script>

<style lang="less" scoped>

</style>